#!/bin/bash
if [ $# != 3 ]; then
    echo "This function checks if an item in file A"
    echo "is in the file B with a list of items"
    echo "The 1st ptr is the file A."
    echo "The 2nd ptr is the file B."
    echo "The 3rd ptr is the col of the item compared"
    exit 
fi
function checkAisInBfile ()
{
    while read A
    do
            itemA=$(echo $A | cut -f $3 -d ' ')
            found='F'
            while read B
            do
                    itemB=$(echo $B | cut -f $3 -d ' ')
                    if [ $itemA == $itemB ]; then
                            found='T'
                            break
                    fi
            done < $2
            if [ $found == 'F' ]; then
                    echo "$A"
            fi
    done < $1
}
checkAisInBfile $1 $2 $3